<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>栏目列表</title>
    <meta name="decorator" content="default"/>
    <%@include file="/WEB-INF/views/include/treetable.jsp" %>
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="栏目管理" />
    <div class="page-content">
        <table id="contentTable" class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th>中文名称</th>
                    <th>英文名称</th>
                    <th>归属机构</th>
                    <th>栏目模型</th>
                    <th style="text-align:center;">排序</th>
                    <th title="是否在导航中显示该栏目">导航菜单</th>
                    <th title="是否在分类页中显示该栏目的文章列表">栏目列表</th>
                    <th>展现方式</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <c:forEach items="${list}" var="tpl">
                <tr id="${tpl.id}" pId="${tpl.parent.id ne '1'?tpl.parent.id:'0'}">
                    <td><a href="JavaScript:;" onclick="treeTableTrtoggle('${tpl.id}');">${tpl.name}</a></td>
                    <td>${tpl.enname}</td>
                    <td>${tpl.office.name}</td>
                    <td>${fns:getDictLabel(tpl.module, 'cms_module', '公共模型')}</td>
                    <td style="text-align:center;">
                        <shiro:hasPermission name="cms:category:edit">
                            <input type="hidden" name="ids" value="${tpl.id}"/>
                            <input name="sorts" type="text" value="${tpl.sort}" style="width:50px;margin:0;padding:0;text-align:center;">
                        </shiro:hasPermission><shiro:lacksPermission name="cms:category:edit">
                        ${tpl.sort}
                    </shiro:lacksPermission>
                    </td>
                    <td>${fns:getDictLabel(tpl.inMenu, 'show_hide', '隐藏')}</td>
                    <td>${fns:getDictLabel(tpl.inList, 'show_hide', '隐藏')}</td>
                    <td>${fns:getDictLabel(tpl.showModes, 'cms_show_modes', '默认展现方式')}</td>
                    <td>
                        <a href="${pageContext.request.contextPath}${fns:getFrontPath()}/list-${tpl.id}${fns:getUrlSuffix()}" target="_blank">访问</a>
                        <shiro:hasPermission name="cms:category:edit">
                            <a href="${ctx}/cms/category/form?id=${tpl.id}">修改</a>
                            <a href="javascript:;" onclick="deleteRecord('${tpl.id}');">删除</a>
                            <a href="${ctx}/cms/category/form?parent.id=${tpl.id}">添加下级栏目</a>
                        </shiro:hasPermission>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
<script>
    $(document).ready(function(){
        $("#contentTable").treeTable({expandLevel : 1});
    });

    function deleteRecord(id){
        layer.confirm("确定要删除该信息吗?",function(index){
            $.post("${ctx}/cms/category/delete",{id:id},function(data){
                if(data.success){
                    layer.alert(data.msg, {icon: 1},function(index){
                        window.location.href = "${ctx}/cms/category/list";
                        layer.close(index);
                    });
                }else{
                    layer.alert(data.msg, {icon: 2});
                }
            layer.close(index);
            });
        });
    }
</script>
</body>
</html>
